﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PIC.IO
{
    public class Microcontroller: INameable
    {
        public List<Port> Ports { get; set; }

        public string Name { get; private set; }

        public Microcontroller(string name)
        {
            Name = name;
        }

        public static Microcontroller GetPic16F871()
        {
            var micro = new Microcontroller("PIC16F871");

            var portA = new Port("PORTA");
            for (int i = 0; i < 5; i++)
                portA.Bits.Add(new Bit("RA" + i));

            var portB = new Port("PORTB");
            for (int i = 0; i < 7; i++)
                portB.Bits.Add(new Bit("RB" + i));

            var portC = new Port("PORTC");
            for (int i = 0; i < 7; i++)
                portC.Bits.Add(new Bit("RC" + i));

            var portD = new Port("PORTD");
            for (int i = 0; i < 7; i++)
                portD.Bits.Add(new Bit("RD" + i));

            var portE = new Port("PORTE");
            for (int i = 0; i < 2; i++)
                portE.Bits.Add(new Bit("RE" + i));

            micro.Ports.Add(portA);
            micro.Ports.Add(portB);
            micro.Ports.Add(portC);
            micro.Ports.Add(portD);
            micro.Ports.Add(portE);

            return micro;
        }

        public override string ToString()
        {
            return Name;
        }

    }
}
